import { getToken, setToken,removeToken} from "@/utils/auth"
import {login} from '@/api/login'

export default {
    namespaced:true,
    state:()=>{
        return {
            token:getToken()
        }
    },
    mutations:{
        setToken(state,token){
            state.token=token
            setToken(token)
        }
    },
    actions:{
        async loginasync({commit},data){
            let res=await login(data)
        console.log(res);
            commit('setToken',res.data.token)
        }
    }
    
}